<template>
  <div class="pagebox">
    <!--  -->
    <crumbs @goBack="goBack" :superiorMenu="['生产设置']" currentMenu="计件单价"></crumbs>
    <a-card :bordered="false" style="margin-top: 12px">
      <a-button @click="handleShowFilter" icon="filter">筛选 <span class="filter-num" style="margin-left: 5px">{{ ' ' + filteredNums() }}</span></a-button>
      <a-button @click="showColumn" icon="unordered-list" class="btns">设置列</a-button>
      <div class="right-btn">
        <PubImport @updateParentData="updateParentData" ref="PubImport" tableCode='MESS_PRODUCT_PROCESS_PRICE' modelName='计件单价导入模板' />
        <!-- <a-button @click="importFile">导入</a-button> -->
        <a-button @click="exportFile" class="btns">导出</a-button>
        <a-button type="primary" style="margin-left: 10px" @click="handleAdd"> +新建 </a-button>
      </div>
      <a-table :key="tableKey" row-key="id" size="middle" :scroll="{ x: scrollX, y: 'calc(100vh - 366px)' }" :hideDefaultSelections="false"
        :row-selection="{
          selectedRowKeys: selectedRowKeys,
          columnTitle: ' ',
          onChange: onSelectChange,
          columnWidth: '60px',
        }" :columns="columns" :dataSource="modelList" :pagination="false" @change="tableChange" class="j-table-force-nowrap" :components="drag(columns, 'PIECE_UNIT_PRICE_LIST')">
        <span slot="actions" slot-scope="text, record">
          <a href="javascript:;" @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a href="javascript:;" @click="handleDelete(record)">删除</a>
        </span>
        <!-- 行信息 -->
        <span slot="processCode" :title="text" slot-scope="text, record" class="btn-text"
          @click="handleDetail(record.processId)">
          {{ text || '-' }}
        </span>
        <span slot="processName" :title="text" slot-scope="text">
          {{  text  }}
        </span>
        <span slot="goodsName" :title="text" slot-scope="text">
          {{  text  }}
        </span>
        <span slot="goodsSpec" :title="text" slot-scope="text">
          {{  text  }}
        </span>
        <!-- 输入框搜索 -->
        <div slot="searchInput" slot-scope="{ selectedKeys, confirm, clearFilters, column }" class="searchWorkOreder">
          <a-input placeholder="请输入" v-model="filterForm[column.dataIndex]" style="width: 188px; display: block" @pressEnter="handleSearch" />
          <a-button type="primary" style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(selectedKeys, confirm, column.dataIndex, clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="searchIcon" slot-scope="filtered" type="search" :style="{ color: filtered ? '#108ee9' : undefined }" />
        <!-- 选择搜索 -->
        <div slot="selectDropdown" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <a-select mode="multiple" allowClear placeholder="请选择" style="width: 200px" v-model="filterForm['type']" @change="(v) => changeStatus(v, 'type')">
            <!-- <a-select-option value="finished_product">成品</a-select-option> -->
            <a-select-option v-for="type in typeList" :key="type.value" :value="type.value">{{
              type.text
            }}</a-select-option>
          </a-select>
          <a-button type="primary" style="width: 80px; margin-left: 20px; display: block" @click="() => handleSearch(confirm, column.dataIndex, clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="selectIcon" slot-scope="filtered" type="filter" :style="{ color: filtered ? '#108ee9' : undefined }" />
        <!-- 人员选择 现版本不做 -->
        <!-- <div slot="selectPeople" slot-scope="{confirm, clearFilters, column }" class='searchWorkOreder'>
          <j-select-user-by-dep @changeRow="userPrinc" v-model="filterForm[column.dataIndex]" :seldep='true' :modalWidth="1000" :multi="true"></j-select-user-by-dep>
          <a-button type="primary" style="width: 80px; margin-left: 20px;display: block;" @click="() => handleSearch(confirm, column.dataIndex,clearFilters)">
            搜索
          </a-button>
        </div>
        <a-icon slot="peopleIcon" slot-scope="filtered" type="filter" :style="{ color: filtered ? '#108ee9' : undefined }" /> -->
      </a-table>
      <SetColumn columnName="设置列" ref="SetColumn" v-if="showSetColumn" @sureBtn="sureBtn" @cancelBtn="showSetColumn = false" />
    </a-card>
    <a-drawer placement="right" width="500" :visible="showFilter" @close="closeFilter">
      <div class="filter-body">
        <div slot="title" class="uni-card filter-tit">
          筛选 <span class="filter-num">{{ filteredNums(1) }}</span>
        </div>
        <div class="uni-card" v-if="filteredNums(1) > 0" style="background: #fff">
          <div v-for="(item, i) in filteredList" :key="i" v-show="item.text" class="tag-wrap">
            <span class="filter-tag" @click="delFiltered(item.key)">
              <span class="tag-text">{{ `${item.title}：${item.text}` }}</span>
              <a-icon type="close" style="float: right" />
            </span>
          </div>
        </div>
        <div style="overflow-y: scroll; flex: 1; padding: 0">
          <div class="uni-card" style="background: #fff">
            <a-form-model ref="ruleForm" layout="vertical" :model="filterForm">
              <a-form-model-item label="工序编号">
                <a-input v-model="filterForm.processCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="工序名称">
                <a-input v-model="filterForm.processName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="产品编号">
                <a-input v-model="filterForm.goodsCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="产品名称">
                <a-input v-model="filterForm.goodsName" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="计价方式">
                <a-select mode="multiple" allowClear placeholder="请选择" style="width: 100%" v-model="filterForm['type']" @change="(v) => changeStatus(v, 'type')">
                  <a-select-option v-for="type in typeList" :key="type.value" :value="type.value">{{
                    type.text
                  }}</a-select-option>
                </a-select>
              </a-form-model-item>
            </a-form-model>
          </div>
        </div>
        <div class="footer-submit">
          <a-button class="margin-btn" @click="resetFilter">重置</a-button>
          <a-button type="primary" @click="handleFilter">确定</a-button>
        </div>
      </div>
    </a-drawer>
    <!-- 全选/分页 -->
    <div class="uni-card resetPadding" :style="{position: 'fixed', bottom:0,right:0,zIndex:2,left:collapsed?'79px':'208px', background: '#fff',paddingLeft:'43px'} ">
      <div style="display: inline-block">
        <a-checkbox :indeterminate="listIndeterminate" :checked="listCheckAll" @change="onCheckAllChange"></a-checkbox>
        <span class="btn-text" style="margin: 0 24px" @click="batchAction">批量删除</span>
        <span style="margin-left: 8px">
          {{ `已选 ${selectedRowKeys.length}/${total} 项` }}
          <span class="btn-text" @click="clearArr" style="margin: 0 10px">清空</span>
        </span>
      </div>
      <div style="display: inline-block; float: right">
        <a-pagination :total="total" v-model="current" :page-size-options="pageSizeOptions" :page-size="pageSize" @change="onChangePage"
          @showSizeChange="onShowSizeChange" show-quick-jumper show-size-changer />
      </div>
    </div>
    <windowForm ref="windowForm" @refresh="handleSearch"></windowForm>
    <windowDetail ref="windowDetail"></windowDetail>
  </div>
</template>
<script>
import SetColumn from '@/pubComponent/SetColumn.vue'
import crumbs from '@/components/crumbs.vue'
import { getNewColumns, subStrText, camelCase2UnderLine } from '@/utils/util'
import { API } from '@/api/requestFzs'
import { ajaxGetDictItems } from '@/api/api'
import { mapState } from 'vuex'
import moment from 'moment'
import { downFilePost } from '@/api/manage'
import PubImport from '@/components/pubBtn/PubImport.vue'
import tableDragResize from '@/mixins/tableDragResize'
// 表头
/* 打开设置列面板123 */
const columnsValue = [
  {
    title: '工序编号',
    width: 180,
    dataIndex: 'processCode',
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'processCode',
    },
  },
  {
    title: '工序名称',
    width: 150,
    dataIndex: 'processName',
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'processName',
    },
  },
  {
    title: '报工单位',
    width: 100,
    ellipsis: true,
    dataIndex: 'processWorkUnit',
    scopedSlots: { customRender: 'processWorkUnit' },
  },
  {
    title: '产品编号',
    width: 180,
    ellipsis: true,
    dataIndex: 'goodsCode',
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'goodsCode',
    },
  },
  {
    title: '产品名称',
    width: 150,
    ellipsis: true,
    dataIndex: 'goodsName',
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'goodsName',
    },
  },
  {
    title: '规格',
    width: 100,
    ellipsis: true,
    dataIndex: 'goodsSpec',
  },
  {
    title: '基本单位',
    width: 100,
    ellipsis: true,
    dataIndex: 'basicUnit',
  },
  {
    title: '计价方式',
    width: 100,
    ellipsis: true,
    dataIndex: 'type',
    scopedSlots: {
      filterDropdown: 'selectDropdown',
      filterIcon: 'selectIcon',
      customRender: 'type',
    },
  },
  {
    title: '计件单价',
    ellipsis: true,
    width: 260,
    dataIndex: 'prices',
  },
  {
    title: '创建时间',
    width: 180,
    ellipsis: true,
    dataIndex: 'createTime',
  },
  {
    title: '创建人',
    width: 150,
    ellipsis: true,
    dataIndex: 'createName',
  },
  // {
  //   fixed: 'right',
  //   title: '操作',

  //   dataIndex: 'actions',
  //   scopedSlots: { customRender: 'actions' },
  // },
]
const actionArr = [
  {
    fixed: 'right',
    title: '操作',
    width: 100,
    dataIndex: 'actions',
    scopedSlots: { customRender: 'actions' },
  },
]
export default {
  mixins: [tableDragResize],
  data() {
    return {
      subStrText,
      //全选按钮
      listIndeterminate: false,
      listCheckAll: false,
      showFilter: false, // 筛选抽屉
      modelList: [], // 列表数据
      selectedRowKeys: [], // 列表已选择数据
      showSetColumn: false, // 显示
      //全选按钮
      indeterminate: false,
      checkAll: false,
      current: 1,
      total: 0,
      pageSize: 10,
      pageSizeOptions: ['10', '20', '30', '40', '50'],
      columns: [
        {
          title: '工序编号',
          width: 180,
          dataIndex: 'processCode',
          ellipsis: true,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'processCode',
          },
        },
        {
          title: '工序名称',
          width: 150,
          dataIndex: 'processName',
          ellipsis: true,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'processName',
          },
        },
        {
          title: '报工单位',
          width: 100,
          ellipsis: true,
          dataIndex: 'processWorkUnit',
          scopedSlots: { customRender: 'processWorkUnit' },
        },
        {
          title: '产品编号',
          width: 180,
          ellipsis: true,
          dataIndex: 'goodsCode',
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'goodsCode',
          },
        },
        {
          title: '产品名称',
          width: 150,
          ellipsis: true,
          dataIndex: 'goodsName',
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'goodsName',
          },
        },
        {
          title: '规格',
          width: 100,
          ellipsis: true,
          dataIndex: 'goodsSpec',
        },
        {
          title: '基本单位',
          width: 100,
          ellipsis: true,
          dataIndex: 'basicUnit',
        },
        {
          title: '计价方式',
          width: 100,
          ellipsis: true,
          dataIndex: 'type',
          scopedSlots: {
            filterDropdown: 'selectDropdown',
            filterIcon: 'selectIcon',
            customRender: 'type',
          },
        },
        {
          title: '计件单价',
          ellipsis: true,
          width: 260,
          dataIndex: 'prices',
        },
        {
          title: '创建时间',
          width: 180,
          ellipsis: true,
          dataIndex: 'createTime',
        },
        {
          title: '创建人',
          width: 150,
          ellipsis: true,
          dataIndex: 'createName',
        },
        // {
        //   fixed: 'right',
        //   title: '操作',
        //   width: 100,
        //   dataIndex: 'actions',
        //   scopedSlots: { customRender: 'actions' },
        // },
      ],
      filterForm: {
        processCode: '',
        processName: '',
        goodsCode: '',
        goodsName: '',
        type: undefined,
      },
      filteredFormLable: {
        processCode: '工序编号',
        processName: '工序名称',
        goodsCode: '产品编号',
        goodsName: '产品名称',
        type: '计价方式',
      },
      sortForm: {
        sortType: '',
        sortColumn: '',
      },
      typeList: [
        {
          value: 'regular',
          text: '常规计价',
        },
        {
          value: 'planned_output',
          text: '计划产量计价',
        },
      ],
      tableKey: 1.9,
      sessionParams: {}
    }
  },
  components: {
    SetColumn,
    crumbs,
    PubImport,
    windowForm: resolve => require(['@/views/skillManagement/pieceUnitPrice/pieceUnitPriceForm'], resolve),
    windowDetail: resolve => require(['@/views/skillManagement/workProcess/workProcessDetail'], resolve),
  },
  computed: {
    scrollX() {
      let xnum = 0
      for (let item of this.columns) {
        xnum += Number(item.width) || 0
      }
      return xnum
    },
    ...mapState({
      collapsed: (state) => state.user.collapsed,
    }),
    hasSelected() {
      return this.selectedRowKeys.length > 0
    },
    filteredList() {
      let list = []
      for (let key in this.filterForm) {
        if (key == 'type' && this.filterForm[key]) {
          list.push({
            title: this.filteredFormLable[key],
            text: this.typeToText(this.filterForm[key]),
            key,
          })
        } else {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm[key],
            key,
          })
        }
      }
      return list
    },
  },
  created() {
    let sessionObj = sessionStorage.getItem(`${this.BUSI_CONST.Entity.PIECE_UNIT_PRICE_LIST}filter`)
    if (sessionObj) {
      let obj = JSON.parse(sessionObj)
      this.filterForm = obj.filterForm
      this.sortForm = obj.sortForm
      this.current = obj.current
      this.pageSize = obj.pageSize
    }
    this.initData()
    this.requestData()
  },
  beforeRouteLeave(to, from, next) {
    if (to.path!='/pieceUnitPriceForm'||JSON.stringify(to.query)=='{}') {
      sessionStorage.removeItem(`${this.BUSI_CONST.Entity.PIECE_UNIT_PRICE_LIST}filter`)
    }
    next()
  },
  mounted() {},
  methods: {
    //更新父组件页面
    updateParentData() {
      this.handleSearch()
    },
    changeStatus(v, key) {
      if (v.length == 0) {
        this.filterForm[key] = undefined
      }
    },
    // 物料类型转文字
    typeToText(v) {
      let text = []
      let typeObj = {}
      for (let i = 0; i < this.typeList.length; i++) {
        const element = this.typeList[i]
        typeObj[element.value] = element.text
      }
      console.log(typeObj)
      v.forEach((value) => {
        text.push(typeObj[value])
      })
      return text.join(',')
    },
    // 排序
    tableChange(pagination, filters, sorter, { currentDataSource }) {
      console.log('看看这是啥33：', sorter)
      if (sorter.order) {
        let sortType = ''
        if (sorter.order == 'ascend') {
          sortType = 'ASC'
        } else {
          sortType = 'DESC'
        }
        this.sortForm = {
          sortType: sortType,
          sortColumn: camelCase2UnderLine(sorter.columnKey),
        }
        this.requestData()
      } else {
        this.sortForm = {
          sortType: '',
          sortColumn: '',
        }
        this.requestData()
      }
    },
    /* 选人 */
    userPrinc(storeVals, row) {
      let uIds = []
      if (row.length > 0) {
        row.forEach((u) => {
          uIds.push(u.id)
        })
        this.filterForm.createByText = uIds.join(',')
      } else {
        this.filterForm.createByText = ''
      }
      this.handleSearch()
    },
    filteredNums(n) {
      let nums = 0
      if (n) {
        for (let key in this.filterForm) {
          if (this.filterForm[key]) {
            nums += 1
          }
        }
      } else {
        for (let key in this.filterForm) {
          if (this.filterForm[key]) {
            nums += 1
          }
        }
      }
      return nums
    },
    handleSearch(selectedKeys, confirm, dataIndex, clearFilters) {
      // confirm() //用来关闭搜索弹窗
      // clearFilters() //用来重置搜索内容
      // console.log('这都是啥00：', selectedKeys)
      // console.log('这都是啥11：', confirm)
      // console.log('这都是啥22：', dataIndex)
      // console.log('这都是啥33：', clearFilters)
      this.current = 1
      this.requestData()
    },
    /* 打开筛选 */
    handleShowFilter() {
      this.showFilter = true
    },
    /* 关闭筛选 */
    closeFilter() {
      this.showFilter = false
    },
    /* 确定筛选 */
    handleFilter() {
      this.handleSearch()
      this.showFilter = false
    },
    /* 删除已选 */
    delFiltered(key) {
      if (key == 'type') {
        this.filterForm[key] = undefined
      } else {
        this.filterForm[key] = ''
      }
    },
    /* 重置筛选 */
    resetFilter() {
      this.filterForm = {
        processCode: '',
        processName: '',
        goodsCode: '',
        goodsName: '',
        type: undefined,
      }
      this.handleSearch()
    },
    /* 初始/加载设置列 */
    initData() {
      var oldValue = localStorage.getItem(this.BUSI_CONST.Entity.PIECE_UNIT_PRICE_LIST)
      this.columns = getNewColumns(columnsValue, JSON.parse(oldValue), actionArr, this.columns)
    },
    /* 请求列表数据 */
    requestData() {
      let obj = {}
      for (let key in this.filterForm) {
        if (this.filterForm[key]) {
          if (key == 'type' && this.filterForm[key]) {
            obj[key] = this.filterForm[key].join(',')
          } else {
            obj[key] = this.filterForm[key]
          }
        }
      }
      let parameter = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...obj,
        ...this.sortForm,
      }
      this.sessionParams = {
        filterForm: this.filterForm,
        sortForm: this.sortForm,
        current: this.current,
        pageSize: this.pageSize,
      }
      API.messProductProcessPriceList(parameter).then((res) => {
        if (res.code == 200) {
          if (res.result.total) {
            this.total = res.result.total
          } else {
            this.total = 0
          }
          this.modelList = res.result.records
        }
      })
    },
    /* 打开设置列面板123 */
    showColumn() {
      this.showSetColumn = true
      this.$nextTick(() => {
        this.$refs.SetColumn.paramsData(columnsValue, this.BUSI_CONST.Entity.PIECE_UNIT_PRICE_LIST, this.columns)
      })
    },
    /* 设置列 */
    sureBtn(emitArr) {
      this.columns = getNewColumns(columnsValue, emitArr, actionArr)
      console.log(this.columns)
      localStorage.setItem(this.BUSI_CONST.Entity.PIECE_UNIT_PRICE_LIST, JSON.stringify(emitArr))
      this.tableKey += 1
    },
    /* 导入 */
    importFile() {},
    /* 导出 */
    exportFile() {
      let that = this
      // 获取动态列
      let filedKeysList = []
      that.columns.forEach((keys) => {
        if (keys.dataIndex != 'actions') {
          filedKeysList.push(keys.dataIndex)
        }
      })
      // filedKeysList.pop()//删除最后一个的操作列
      let filedKeys = filedKeysList.join(',')
      //设置文件名
      let fileName = `计件单价${moment().format('YYYY-MM-DD HH:mm')}`
      let param = {
        ...that.filterForm,
        ...that.sortForm,
        fileName: fileName,
        filedKeys: filedKeys,
      }
      for (let key in param) {
        if (!!param[key] || param[key] === 0) {
          // nothing
        } else {
          delete param[key]
        }
      }
      that.$antdConfirm({
        title: `确定导出全部数据?`,
        onOk() {
          console.log(param, '导出选中数据param')
          downFilePost('/prices/messProductProcessPrice/exportExcel', param).then((data) => {
            if (data.type == 'application/json') {
              const reader = new FileReader() //创建一个FileReader实例
              reader.readAsText(data, 'utf-8') //读取文件,结果用字符串形式表示
              reader.onload = function () {
                //读取完成后,**获取reader.result**
                const msg = JSON.parse(reader.result)
                that.$antdMessage.error(msg.message) //弹出错误提示
              }
              return
            }
            if (!data) {
              this.$antdMessage.error('导出失败')
              return
            }
            if (typeof window.navigator.msSaveBlob !== 'undefined') {
              window.navigator.msSaveBlob(new Blob([data]), fileName + '.xls')
            } else {
              let url = window.URL.createObjectURL(new Blob([data]))
              let link = document.createElement('a')
              link.style.display = 'none'
              link.href = url
              link.setAttribute('download', fileName + '.xls')
              document.body.appendChild(link)
              link.click()
              document.body.removeChild(link) //下载完成移除元素
              window.URL.revokeObjectURL(url) //释放掉blob对象
            }
          })
        },
        onCancel() {},
      })
    },
    /* 新建 */
    handleAdd() {
      this.$refs.windowForm.initForm()
    },
    /* 编辑 */
    handleEdit(v) {
      sessionStorage.setItem(`${this.BUSI_CONST.Entity.PIECE_UNIT_PRICE_LIST}filter`, JSON.stringify(this.sessionParams))
      this.$refs.windowForm.initForm(v.id)
    },
    /* 详情 */
    handleDetail(id) {
      this.$refs.windowDetail.initDetail(id)
    },
    /* 删除 */
    handleDelete(v) {
      let that = this
      that.$antdConfirm({
        title: '请确定要删除吗？',
        content: ``,
        onOk() {
          API.messProductProcessPriceDelete({ id: v.id }).then((res) => {
            if (res.code == 200) {
              that.$antdMessage.success('删除成功！')
              if (that.modelList.length === 1) {
                that.current = that.current == 1 ? 1 : that.current - 1
              }
              that.requestData()
            } else {
              that.$antdMessage.error('删除失败！')
            }
          })
        },
        onCancel() {},
      })
    },
    //点击返回按钮
    goBack() {
      console.log('goback')
    },
    /* 列表选择 */
    onSelectChange(selectedRowKeys) {
      console.log('selectedRowKeys changed: ', selectedRowKeys)
      this.selectedRowKeys = selectedRowKeys
    },
    // 全选
    onCheckAllChange(e) {
      if (e.target.checked) {
        for (let item of this.modelList) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            console.log('each != item.id:', each != item.id)
            return each != item.id
          })
          this.selectedRowKeys.push(item.id)
        }
      } else {
        for (let item of this.modelList) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            console.log('each != item.id:', each != item.id)
            return each != item.id
          })
        }
      }
      this.checkBoxStatus()
    },
    checkBoxStatus() {
      if (this.selectedRowKeys.length == 0) {
        this.listIndeterminate = false
        this.listCheckAll = false
      } else {
        let tableIds = []
        for (let item of this.modelList) {
          tableIds.push(item.id)
        }
        let checkValue = this.isInclude(tableIds, this.selectedRowKeys)
        console.log('第一个参数是；', checkValue)
        if (checkValue) {
          this.listIndeterminate = false
          this.listCheckAll = true
        } else {
          this.listIndeterminate = true
          this.listCheckAll = false
        }
      }
    },
    isInclude(aa, bb) {
      return aa.every((item) => {
        return bb.some((sub) => {
          return sub === item
        })
      })
    },
    // 批量删除
    batchAction() {
      let that = this
      if (that.selectedRowKeys.length > 0) {
        let ids = that.selectedRowKeys.join(',')
        that.$antdConfirm({
          title: '请确定要删除吗?',
          content: `共选中${that.selectedRowKeys.length}条信息`,
          onOk() {
            that.clearArr()
            API.messProductProcessPriceDelBatchMain({ ids }).then((res) => {
              if (res.code == 200) {
                that.$antdMessage.success('删除成功！')
                that.handleSearch()
              } else {
                that.$antdMessage.error(res.message)
              }
            })
          },
          onCancel() {},
        })
      } else {
        that.$antdMessage.info('请先选择数据')
      }
    },
    /* 清除 */
    clearArr() {
      this.selectedRowKeys = []
      this.checkBoxStatus()
    },
    // 分页
    onChangePage(current, pageSize) {
      this.current = current
      this.pageSize = pageSize
      this.requestData()
    },
    onShowSizeChange(current, pageSize) {
      this.current = current
      this.pageSize = pageSize
      this.requestData()
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/public.less';
.btn-text-none {
  color: #888888;
}
a {
  margin: 0;
}
.flex(@jc,@ai,@fd:row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}
.header {
  width: 150%;
  margin: -12px -12px @distance4;
}
.backBox {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  .backC {
    cursor: pointer;
    display: flex;
    align-items: center;
  }
}
.j-table-force-nowrap {
  margin-top: @distance1;
}
.btns {
  margin-left: @distance5;
}
.right-btn {
  float: right;
  display: flex;
  justify-content: flex-end;
}
.mg-left {
  margin-left: @distance3;
}
.filter-tit {
  background: #fff;
  border-bottom: 1px solid @greyBorder;
  font-size: @fontSize4;
}
.filter-num {
  color: @normalFont;
}
.filter-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.margin-btn {
  margin-right: @distance5;
}
.filter-tag {
  display: inline-block;
  position: relative;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: @fontSize1;
  line-height: @fontSize1;
  max-width: 100%;
  background: @greyBg;
  color: @titFont;
  cursor: pointer;
  .tag-text {
    display: inline-block;
    padding-right: 20px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .anticon-close {
    position: absolute;
    right: 8px;
    top: 8px;
  }
}
.tag-wrap:nth-of-type(n + 2) {
  margin-top: 10px;
}
.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}
.pagebox {
  /deep/ .ant-card-body {
    height: calc(100vh - 214px);
    overflow: hidden;
    padding: 20px 16px;
  }
}
</style>
